package com.michaelbulava.TFS.ui.config;

import com.michaelbulava.TFS.persistence.IdeaPersistenceStoreProvider;
import com.microsoft.tfs.core.config.ConnectionInstanceData;
import com.microsoft.tfs.core.config.DefaultConnectionAdvisor;
import com.microsoft.tfs.core.config.httpclient.ConfigurableHTTPClientFactory;
import com.microsoft.tfs.core.config.persistence.DefaultPersistenceStoreProvider;
import com.microsoft.tfs.core.config.persistence.PersistenceStoreProvider;
import com.microsoft.tfs.core.config.webservice.DefaultWebServiceFactory;
import com.microsoft.tfs.core.config.webservice.WebServiceFactory;

import java.util.Locale;
import java.util.TimeZone;

/**
 * Created by mbulava on 5/6/2015.
 */
public class ClientConnectionAdvisor extends DefaultConnectionAdvisor {
    public ClientConnectionAdvisor() {
        super(Locale.getDefault(), TimeZone.getDefault());
    }

    @Override
    public WebServiceFactory getWebServiceFactory(ConnectionInstanceData instanceData){
        return new DefaultWebServiceFactory(getLocale(instanceData), new UITransportRequestHandler(instanceData,
                (ConfigurableHTTPClientFactory)getHTTPClientFactory(instanceData)));
    }

    @Override
    public PersistenceStoreProvider getPersistenceStoreProvider(ConnectionInstanceData instanceData) {
        return IdeaPersistenceStoreProvider.INSTANCE;
    }
}
